#include "prec.h"
#include "imagefactory.h"
#include "pathhelper.h"
#include "wx/log.h"

ImageCacheMap ImageFactory::ms_cache;

wxBitmap ImageFactory::GetBitmap( const wxString& name, wxBitmapType btype )
{
	ImageCacheMap::iterator it = ms_cache.find(name);
	if (it != ms_cache.end())
	{
		return it->second;
	}

	wxString filename = PathHelper::GetFile(wxT("images"), name);
	wxBitmap bmp(filename, wxBITMAP_TYPE_PNG);

	if (bmp.IsOk())
	{
		ms_cache[name] = bmp;
		return ms_cache[name];
	}
	
	return wxNullBitmap;
}